<template>
	<view class="pages">
		<u-sticky bgColor="#fff" height="60">
			<u-tabs :list="list1" lineWidth="30" activeStyle="color: #4ca0fd" itemStyle="padding:0 25px;height: 35px;"
				@click="click"></u-tabs>
		</u-sticky>

		<view class="list_box">
			<template v-if="shopList.length != 0">
				<view class="availabilityList" v-for="(itemshop,indexshop) in shopList" :key="indexshop">

					<view class="shopList">
						<u--image :src="itemshop.media_url || '../../../static/default/default.png'" width="100px"
							height="100px" radius="5" @click="detail(itemshop)"></u--image>
						<view class="description">
							<view class="title">
								<view class="description_title">
									{{itemshop.name}}
								</view>
								<view class="titleType primary " v-if="index == 0">
									待确认
								</view>

								<view class="titleType success" v-if="index == 1">
									已确认
								</view>
								<view class="titleType error" v-if="index == 2">
									已取消
								</view>
								<view class="titleType error" v-if="index == 3">
									已拒绝
								</view>
							</view>
							<view class="description_squaremetre" @click="detail(itemshop)">
								{{ itemshop.tenant_name }}
							</view>
							<view class="description_squaremetre" @click="detail(itemshop)">
								{{ itemshop.collection_channel }}
							</view>
							<view class="button_row" @click="detail(itemshop)">
								<view  v-for="(tagItem, tagIndex) of changeList(itemshop.labels)" :key="tagIndex" style="margin: 5rpx;"> 
									<u-tag type="info" shape="circle" plain  size="mini" :text="tagItem" borderColor="#c7c7c7"></u-tag>
								</view>
								<!-- <view class="button_1" v-for="(tagItem, tagIndex) of changeList(itemshop.labels)"
									:key="tagIndex" :style="{backgroundColor: labelsColor[tagIndex]}">
									{{tagItem}}
								</view> -->
							</view>
							<view class="row">
								<view class="money">
									{{itemshop.rent}}
									<view class="unit">
										元/月
									</view>
								</view>
							</view>
							<view class="buttonRow">
								<view style="display: inline-block; width: 30%;" v-if="index !== 3">
									<u-button type="primary" size="small"
										text="查看合同" @click="detail(itemshop)"></u-button>
								</view>
								<view style="display: inline-block; width: 30%;" v-if="index == 3">
									<u-button type="info" size="small" :plain="true" :hairline="true"
										text="查看合同" @click="detail(itemshop)"></u-button>
								</view>
							</view>
						<!-- 	<view class="buttonRow_" v-if="index == 3">
								<u-button text="删除签约" size="small"  :plain="true" shape="circle"
									@click="deleteAgency"></u-button>
							</view> -->
							
						</view>
					</view>

				</view>
			</template>
		</view>
		<view class="" v-if="shopList.length == 0">
			<u-empty icon="https://cdn.uviewui.com/uview/empty/data.png">
			</u-empty>
		</view>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	import {
		landgetConfirm
	} from "@/api/home/index.js"

	export default {
		data() {
			return {
				index: 0,
				list1: [{
						name: '未确认',
					}, {
						name: '已确认',
					},
					{
						name: '已取消',
					}, {
						name: '已拒绝'
					}
				],
				labelsColor: ['#3c9cff', '#f9ae3d', '#5ac725', '#f56c6c', '#e3e3e3'],
				shopList: [],
				orderInfo:{}
			}
				
		},
		onLoad() {
			this.getList();
		},
		methods: {
			changeList(str) {
				var labels = ""
				if (str) {
					labels = str.split(',')
				} else {
					labels = []
				}
				return labels
			},

			async getList() {
				const res = await landgetConfirm(this.index)
				if (res.data.code != 200) return this.$refs.uToast.show({
					message: res.data.msg,
					type: 'error'
				})

				this.shopList = res.data.data
			},
			click(item) {

				this.index = item.index;
				this.getList();
			},
			detail(item) {
				uni.navigateTo({
					url: './viewDetail?id=' + item.lease_id,
					animationType: this.animation.type,
					animationDuration: this.animation.time
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "~@/styles/index.scss";
	@import "~@/styles/global.scss";

	.list_box {
		padding: 0 30rpx;
		box-sizing: border-box;
	}

	.pages {
		width: 100%;
		max-height: 100%;
		min-height: 100vh;

		// background-color: $pagebgc;
		.availabilityList {
			width: 100%;
			box-sizing: border-box;
			padding: 20rpx;
			@include boxshadow;
			margin-top: 30rpx;
			border-radius: 20rpx;

			.tiem {
				// text-align: center;
				color: #7f7f7f;
				font-size: 24rpx;
				padding: 20rpx 0;
			}

			.shopList {
				border-radius: 10rpx;
				display: flex;
				// padding: 20rpx;
				margin-bottom: 20rpx;
				background-color: white;

				.description {
					width: 100%;
					margin-left: 20rpx;

					.title {
						display: flex;
						justify-content: space-between;
						align-items: center;

						.description_title {
							font-weight: bold;
							font-size: 36rpx;
						}

						.titleType {
							font-weight: bold;
							font-size: 32rpx;
						}

						.success {
							color: #7f7f7f;
						}

						.error {
							color: #d02d37;
						}

						.primary {
							color: #79b8f4;
						}
					}

					.description_squaremetre {
						color: #7f7f7f;
						font-size: 28rpx;
						line-height: 60rpx
					}
				}
				.buttonRow{
					display: flex;
					justify-content: flex-end;
				}
				.buttonRow_{
					width: 30%;
					margin-left: auto;
				}

				.button_row {
					display: flex;
					justify-content: flex-start;
					flex-wrap: wrap;
					overflow: hidden;
					text-overflow: ellipsis;  
					margin-top: 20rpx;
				}

				.row {
					display: flex;
					justify-content: space-between;
					align-items: center;
					margin: 5rpx 0;

					.money {
						font-weight: bold;
						font-size: 42rpx;
						color: red;
						display: flex;
						align-items: center;

						.unit {
							font-size: 28rpx;
						}
					}

					.buttom {
						display: flex;
						align-items: center;

						.custom-style {
							margin-left: 10rpx;
						}
					}

				}

			}
		}
	}
</style>